<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
             label-width="68px">
      <el-form-item label="记录日期" prop="recordDate">
        <el-date-picker clearable
                        v-model="queryParams.recordDate"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择记录日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="现金收入" prop="cash">
        <el-input
          v-model="queryParams.cash"
          placeholder="请输入现金收入"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="鲁通卡收入" prop="lutongCard">
        <el-input
          v-model="queryParams.lutongCard"
          placeholder="请输入鲁通卡收入"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="银联收入" prop="unionpay">
        <el-input
          v-model="queryParams.unionpay"
          placeholder="请输入银联收入"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手撕票收入" prop="handTearTicket">
        <el-input
          v-model="queryParams.handTearTicket"
          placeholder="请输入手撕票收入"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="收入总计" prop="totalRevenue">
        <el-input
          v-model="queryParams.totalRevenue"
          placeholder="请输入收入总计"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="卡赔收入" prop="cardCompensation">
        <el-input
          v-model="queryParams.cardCompensation"
          placeholder="请输入卡赔收入"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入口客车数量" prop="entrancePassenger">
        <el-input
          v-model="queryParams.entrancePassenger"
          placeholder="请输入入口客车数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入口货车数量" prop="entranceFreight">
        <el-input
          v-model="queryParams.entranceFreight"
          placeholder="请输入入口货车数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入口纸卡数量" prop="entrancePaperCard">
        <el-input
          v-model="queryParams.entrancePaperCard"
          placeholder="请输入入口纸卡数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入口节假日免费车数量" prop="entranceHolidayFree">
        <el-input
          v-model="queryParams.entranceHolidayFree"
          placeholder="请输入入口节假日免费车数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入口车流总计" prop="entranceSubtotal">
        <el-input
          v-model="queryParams.entranceSubtotal"
          placeholder="请输入入口车流总计"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入口CPC车流" prop="entranceCpc">
        <el-input
          v-model="queryParams.entranceCpc"
          placeholder="请输入入口CPC车流"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入口CPC车流比例" prop="entranceCpcRatio">
        <el-input
          v-model="queryParams.entranceCpcRatio"
          placeholder="请输入入口CPC车流比例"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入口ETC车流" prop="entranceEtc">
        <el-input
          v-model="queryParams.entranceEtc"
          placeholder="请输入入口ETC车流"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入口ETC车流比例" prop="entranceEtcRatio">
        <el-input
          v-model="queryParams.entranceEtcRatio"
          placeholder="请输入入口ETC车流比例"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出口客车数量" prop="exitPassenger">
        <el-input
          v-model="queryParams.exitPassenger"
          placeholder="请输入出口客车数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出口货车数量" prop="exitFreight">
        <el-input
          v-model="queryParams.exitFreight"
          placeholder="请输入出口货车数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出口纸卡数量" prop="exitPaperCard">
        <el-input
          v-model="queryParams.exitPaperCard"
          placeholder="请输入出口纸卡数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出口节假日免费车数量" prop="exitHolidayFree">
        <el-input
          v-model="queryParams.exitHolidayFree"
          placeholder="请输入出口节假日免费车数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出口车流总计" prop="exitSubtotal">
        <el-input
          v-model="queryParams.exitSubtotal"
          placeholder="请输入出口车流总计"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出口CPC车流" prop="exitCpc">
        <el-input
          v-model="queryParams.exitCpc"
          placeholder="请输入出口CPC车流"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出口CPC车流比例" prop="exitCpcRatio">
        <el-input
          v-model="queryParams.exitCpcRatio"
          placeholder="请输入出口CPC车流比例"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出口ETC车流" prop="exitEtc">
        <el-input
          v-model="queryParams.exitEtc"
          placeholder="请输入出口ETC车流"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出口ETC车流比例" prop="exitEtcRatio">
        <el-input
          v-model="queryParams.exitEtcRatio"
          placeholder="请输入出口ETC车流比例"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出入口合计车流量" prop="totalTrafficFlow">
        <el-input
          v-model="queryParams.totalTrafficFlow"
          placeholder="请输入出入口合计车流量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="绿通车数量" prop="greenChannelCount">
        <el-input
          v-model="queryParams.greenChannelCount"
          placeholder="请输入绿通车数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="绿通车金额" prop="greenChannelAmount">
        <el-input
          v-model="queryParams.greenChannelAmount"
          placeholder="请输入绿通车金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注" prop="note">
        <el-input
          v-model="queryParams.note"
          placeholder="请输入备注"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="导入时间" prop="importTime">
        <el-date-picker clearable
                        v-model="queryParams.importTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择导入时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['biz:trafficRecord:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['biz:trafficRecord:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['biz:trafficRecord:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['biz:trafficRecord:export']"
        >导出
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-import"
          size="mini"
          @click="handleImport"
          v-hasPermi="['biz:trafficRecord:import']"
        >导入
        </el-button>
      </el-col>

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="trafficRecordList"
              @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="自动增加的唯一ID" align="center" prop="id"/>
      <el-table-column label="记录日期" align="center" prop="recordDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.recordDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="现金收入" align="center" prop="cash"/>
      <el-table-column label="鲁通卡收入" align="center" prop="lutongCard"/>
      <el-table-column label="银联收入" align="center" prop="unionpay"/>
      <el-table-column label="手撕票收入" align="center" prop="handTearTicket"/>
      <el-table-column label="收入总计" align="center" prop="totalRevenue"/>
      <el-table-column label="卡赔收入" align="center" prop="cardCompensation"/>
      <el-table-column label="入口客车数量" align="center" prop="entrancePassenger"/>
      <el-table-column label="入口货车数量" align="center" prop="entranceFreight"/>
      <el-table-column label="入口纸卡数量" align="center" prop="entrancePaperCard"/>
      <el-table-column label="入口节假日免费车数量" align="center" prop="entranceHolidayFree"/>
      <el-table-column label="入口车流总计" align="center" prop="entranceSubtotal"/>
      <el-table-column label="入口CPC车流" align="center" prop="entranceCpc"/>
      <el-table-column label="入口CPC车流比例" align="center" prop="entranceCpcRatio"/>
      <el-table-column label="入口ETC车流" align="center" prop="entranceEtc"/>
      <el-table-column label="入口ETC车流比例" align="center" prop="entranceEtcRatio"/>
      <el-table-column label="出口客车数量" align="center" prop="exitPassenger"/>
      <el-table-column label="出口货车数量" align="center" prop="exitFreight"/>
      <el-table-column label="出口纸卡数量" align="center" prop="exitPaperCard"/>
      <el-table-column label="出口节假日免费车数量" align="center" prop="exitHolidayFree"/>
      <el-table-column label="出口车流总计" align="center" prop="exitSubtotal"/>
      <el-table-column label="出口CPC车流" align="center" prop="exitCpc"/>
      <el-table-column label="出口CPC车流比例" align="center" prop="exitCpcRatio"/>
      <el-table-column label="出口ETC车流" align="center" prop="exitEtc"/>
      <el-table-column label="出口ETC车流比例" align="center" prop="exitEtcRatio"/>
      <el-table-column label="出入口合计车流量" align="center" prop="totalTrafficFlow"/>
      <el-table-column label="绿通车数量" align="center" prop="greenChannelCount"/>
      <el-table-column label="绿通车金额" align="center" prop="greenChannelAmount"/>
      <el-table-column label="备注" align="center" prop="note"/>
      <el-table-column label="导入时间" align="center" prop="importTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.importTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['biz:trafficRecord:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['biz:trafficRecord:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改通行记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="记录日期" prop="recordDate">
          <el-date-picker clearable
                          v-model="form.recordDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择记录日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="现金收入" prop="cash">
          <el-input v-model="form.cash" placeholder="请输入现金收入"/>
        </el-form-item>
        <el-form-item label="鲁通卡收入" prop="lutongCard">
          <el-input v-model="form.lutongCard" placeholder="请输入鲁通卡收入"/>
        </el-form-item>
        <el-form-item label="银联收入" prop="unionpay">
          <el-input v-model="form.unionpay" placeholder="请输入银联收入"/>
        </el-form-item>
        <el-form-item label="手撕票收入" prop="handTearTicket">
          <el-input v-model="form.handTearTicket" placeholder="请输入手撕票收入"/>
        </el-form-item>
        <el-form-item label="收入总计" prop="totalRevenue">
          <el-input v-model="form.totalRevenue" placeholder="请输入收入总计"/>
        </el-form-item>
        <el-form-item label="卡赔收入" prop="cardCompensation">
          <el-input v-model="form.cardCompensation" placeholder="请输入卡赔收入"/>
        </el-form-item>
        <el-form-item label="入口客车数量" prop="entrancePassenger">
          <el-input v-model="form.entrancePassenger" placeholder="请输入入口客车数量"/>
        </el-form-item>
        <el-form-item label="入口货车数量" prop="entranceFreight">
          <el-input v-model="form.entranceFreight" placeholder="请输入入口货车数量"/>
        </el-form-item>
        <el-form-item label="入口纸卡数量" prop="entrancePaperCard">
          <el-input v-model="form.entrancePaperCard" placeholder="请输入入口纸卡数量"/>
        </el-form-item>
        <el-form-item label="入口节假日免费车数量" prop="entranceHolidayFree">
          <el-input v-model="form.entranceHolidayFree" placeholder="请输入入口节假日免费车数量"/>
        </el-form-item>
        <el-form-item label="入口车流总计" prop="entranceSubtotal">
          <el-input v-model="form.entranceSubtotal" placeholder="请输入入口车流总计"/>
        </el-form-item>
        <el-form-item label="入口CPC车流" prop="entranceCpc">
          <el-input v-model="form.entranceCpc" placeholder="请输入入口CPC车流"/>
        </el-form-item>
        <el-form-item label="入口CPC车流比例" prop="entranceCpcRatio">
          <el-input v-model="form.entranceCpcRatio" placeholder="请输入入口CPC车流比例"/>
        </el-form-item>
        <el-form-item label="入口ETC车流" prop="entranceEtc">
          <el-input v-model="form.entranceEtc" placeholder="请输入入口ETC车流"/>
        </el-form-item>
        <el-form-item label="入口ETC车流比例" prop="entranceEtcRatio">
          <el-input v-model="form.entranceEtcRatio" placeholder="请输入入口ETC车流比例"/>
        </el-form-item>
        <el-form-item label="出口客车数量" prop="exitPassenger">
          <el-input v-model="form.exitPassenger" placeholder="请输入出口客车数量"/>
        </el-form-item>
        <el-form-item label="出口货车数量" prop="exitFreight">
          <el-input v-model="form.exitFreight" placeholder="请输入出口货车数量"/>
        </el-form-item>
        <el-form-item label="出口纸卡数量" prop="exitPaperCard">
          <el-input v-model="form.exitPaperCard" placeholder="请输入出口纸卡数量"/>
        </el-form-item>
        <el-form-item label="出口节假日免费车数量" prop="exitHolidayFree">
          <el-input v-model="form.exitHolidayFree" placeholder="请输入出口节假日免费车数量"/>
        </el-form-item>
        <el-form-item label="出口车流总计" prop="exitSubtotal">
          <el-input v-model="form.exitSubtotal" placeholder="请输入出口车流总计"/>
        </el-form-item>
        <el-form-item label="出口CPC车流" prop="exitCpc">
          <el-input v-model="form.exitCpc" placeholder="请输入出口CPC车流"/>
        </el-form-item>
        <el-form-item label="出口CPC车流比例" prop="exitCpcRatio">
          <el-input v-model="form.exitCpcRatio" placeholder="请输入出口CPC车流比例"/>
        </el-form-item>
        <el-form-item label="出口ETC车流" prop="exitEtc">
          <el-input v-model="form.exitEtc" placeholder="请输入出口ETC车流"/>
        </el-form-item>
        <el-form-item label="出口ETC车流比例" prop="exitEtcRatio">
          <el-input v-model="form.exitEtcRatio" placeholder="请输入出口ETC车流比例"/>
        </el-form-item>
        <el-form-item label="出入口合计车流量" prop="totalTrafficFlow">
          <el-input v-model="form.totalTrafficFlow" placeholder="请输入出入口合计车流量"/>
        </el-form-item>
        <el-form-item label="绿通车数量" prop="greenChannelCount">
          <el-input v-model="form.greenChannelCount" placeholder="请输入绿通车数量"/>
        </el-form-item>
        <el-form-item label="绿通车金额" prop="greenChannelAmount">
          <el-input v-model="form.greenChannelAmount" placeholder="请输入绿通车金额"/>
        </el-form-item>
        <el-form-item label="备注" prop="note">
          <el-input v-model="form.note" placeholder="请输入备注"/>
        </el-form-item>
        <el-form-item label="导入时间" prop="importTime">
          <el-date-picker clearable
                          v-model="form.importTime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择导入时间">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px">
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <el-checkbox v-model="upload.updateSupport"/>
          是否更新已经存数据
          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">
          提示：仅允许导入“xls”或“xlsx”格式文件！
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import {
  listTrafficRecord,
  importTrafficRecord,
  getTrafficRecord,
  delTrafficRecord,
  addTrafficRecord,
  updateTrafficRecord
} from "@/api/biz/trafficRecord";
import { getToken } from "@/utils/auth";

export default {
  name: "TrafficRecord",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 通行记录表格数据
      trafficRecordList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        recordDate: null,
        cash: null,
        lutongCard: null,
        unionpay: null,
        handTearTicket: null,
        totalRevenue: null,
        cardCompensation: null,
        entrancePassenger: null,
        entranceFreight: null,
        entrancePaperCard: null,
        entranceHolidayFree: null,
        entranceSubtotal: null,
        entranceCpc: null,
        entranceCpcRatio: null,
        entranceEtc: null,
        entranceEtcRatio: null,
        exitPassenger: null,
        exitFreight: null,
        exitPaperCard: null,
        exitHolidayFree: null,
        exitSubtotal: null,
        exitCpc: null,
        exitCpcRatio: null,
        exitEtc: null,
        exitEtcRatio: null,
        totalTrafficFlow: null,
        greenChannelCount: null,
        greenChannelAmount: null,
        note: null,
        importTime: null
      },
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + '/biz/trafficRecord/importData'
      },


      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询通行记录列表 */
    getList() {
      this.loading = true;
      listTrafficRecord(this.queryParams).then(response => {
        this.trafficRecordList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        recordDate: null,
        cash: null,
        lutongCard: null,
        unionpay: null,
        handTearTicket: null,
        totalRevenue: null,
        cardCompensation: null,
        entrancePassenger: null,
        entranceFreight: null,
        entrancePaperCard: null,
        entranceHolidayFree: null,
        entranceSubtotal: null,
        entranceCpc: null,
        entranceCpcRatio: null,
        entranceEtc: null,
        entranceEtcRatio: null,
        exitPassenger: null,
        exitFreight: null,
        exitPaperCard: null,
        exitHolidayFree: null,
        exitSubtotal: null,
        exitCpc: null,
        exitCpcRatio: null,
        exitEtc: null,
        exitEtcRatio: null,
        totalTrafficFlow: null,
        greenChannelCount: null,
        greenChannelAmount: null,
        note: null,
        importTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加通行记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getTrafficRecord(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改通行记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateTrafficRecord(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTrafficRecord(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },


    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除通行记录编号为"' + ids + '"的数据项？').then(function () {
        return delTrafficRecord(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('biz/trafficRecord/export', {
        ...this.queryParams
      }, `trafficRecord_${new Date().getTime()}.xlsx`)
    },

    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "用户导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('honor/honor/importTemplate', {}, `user_template_${new Date().getTime()}.xlsx`)
    },
// 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
// 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      // this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
// 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    }
  }
};
</script>
